#include "timeparameterset.h"
#include "ui_timeparameterset.h"
#include "usermysqls.h"
Q_GLOBAL_STATIC(TimeParameterSet,theInstance);
TimeParameterSet::TimeParameterSet(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::TimeParameterSet)
{
    ui->setupUi(this);
    this->setWindowTitle("时间参数设置界面");
    this->setWindowIcon(QIcon(":res/res/TimeSet"));
    initSpinBoxRange();
}

TimeParameterSet *TimeParameterSet::instance()
{
return theInstance;
}

TimeParameterSet::~TimeParameterSet()
{
    delete ui;
}



void TimeParameterSet::on_pushButtonExit_clicked()
{
    this->close();//退出设置关闭界面
}

void TimeParameterSet::initSpinBoxRange()
{
ui->spinBoxDataCycle->setRange(0,10);
ui->spinBoxFrequencyCycle->setRange(0,10);
ui->spinBoxWarningCycle->setRange(0,10);
ui->spinBoxSensorCycle->setRange(0,10);
ui->spinBoxCurveCycle->setRange(0,10);
}


void TimeParameterSet::on_pushButtonConfirm_clicked()
{
extern QVector<int>TimeCycleSets;

if(ui->checkBoxDataCycle->isChecked())
{
 TimeCycleSets[0]=ui->spinBoxDataCycle->value();
 UserMysqlS::instance()->updateTimeCycleSets(0);
}

if(ui->checkBoxFrequencyCycle->isChecked())
{
 TimeCycleSets[1]=ui->spinBoxFrequencyCycle->value();
 UserMysqlS::instance()->updateTimeCycleSets(1);
}

if(ui->checkBoxWarningCycle->isChecked())
{
 TimeCycleSets[2]=ui->spinBoxWarningCycle->value();
 UserMysqlS::instance()->updateTimeCycleSets(2);
}
if(ui->checkBoxSensorCycle->isChecked())
{
 TimeCycleSets[3]=ui->spinBoxSensorCycle->value();
 UserMysqlS::instance()->updateTimeCycleSets(3);
}
if(ui->checkBoxCurveCycle->isChecked())
{
 TimeCycleSets[4]=ui->spinBoxCurveCycle->value();
 UserMysqlS::instance()->updateTimeCycleSets(4);
}

}

